package com.itcast.cn.myhashset;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @PackageName: com.itcast.cn.myhashset
 * @ClassName: HashSetDemo01
 * @Author: wusong
 * @Date: 2020/7/6 0006 15:48
 * @Description:
 */
public class HashSetDemo01 {
    public static void main(String[] args) {
        HashSet<String> hs = new HashSet<>();
        hs.add("nihao");
        hs.add("java");
        hs.add("hello");
        hs.add("world");
        hs.add("java");
        hs.add("java");
        Iterator<String> it = hs.iterator();
        while (it.hasNext()){
            final String s = it.next();
            System.out.println(s);
        }
        System.out.println("===================================");
        for (String s : hs) {
            System.out.println(s);
        }
    }
}

